﻿var oracledb = require('oracledb');
var dbConfig = require('../util/dbconfig.js');

exports.execute = function (req, res) {
	oracledb.getConnection(
	  {
	    user          : dbConfig.user,
	    password      : dbConfig.password,
	    connectString : dbConfig.connectString
	  })
	  .then(function(connection) {
	    return connection.execute(
	      "SELECT * from tab",
		{},{outFormat:oracledb.OBJECT}
	    )
	      .then(function(result) {
	        //console.log(result.metaData);
	        //console.log(result.rows);
	        res.send(result.rows);

	        return connection.release();
	      })
	      .catch(function(err) {
	        console.log(err.message);

	        return connection.release();
	      });
	  })
	  .catch(function(err) {
	    console.error(err.message);
	  });
  
	};